<%--
  Created by IntelliJ IDEA.
  User: 32104
  Date: 2023/9/20
  Time: 16:28
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" +
            request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fml" uri="http://java.sun.com/jstl/fmt_rt" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="<%=basePath%>static/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="<%=basePath%>static/css/font.css">
    <link rel="stylesheet" href="<%=basePath%>static/css/xadmin.css">
    <script type="text/javascript" src="<%=basePath%>static/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="<%=basePath%>static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=basePath%>static/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="paymentid" class="layui-form-label">
                <span class="x-red">*</span>支付id
            </label>
            <div class="layui-input-inline">
                <input type="text" id="paymentid" name="paymentid" readonly
                       autocomplete="off" class="layui-input" value="${payment.paymentid}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="orderid" class="layui-form-label">
                订单id
            </label>
            <div class="layui-input-inline">
                <input type="orderid" id="orderid" name="orderid" readonly
                       autocomplete="off" class="layui-input" value="${payment.orderid}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label for="paymenttime" class="layui-form-label">支付时间</label>
                <div class="layui-input-inline">
                    <input type="datetime-local" class="layui-input" id="paymenttime" placeholder="yyyy-MM-dd HH:mm"
                       value="<fml:formatDate value="${payment.paymenttime}" pattern="yyyy-MM-dd HH:mm"></fml:formatDate>">

                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="paymentmount" class="layui-form-label">
                支付价格
            </label>
            <div class="layui-input-inline">
                <input type="paymentmount" id="paymentmount" name="paymentmount"
                       autocomplete="off" class="layui-input" value="${payment.paymentmount}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="paymentstatus" class="layui-form-label">
                支付状态
            </label>
            <div class="layui-input-inline">
                <input type="paymentstatus" id="paymentstatus" name="paymentstatus"
                       class="layui-input" value="${payment.paymentstatus}">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" id="L_repass" type="button">
                修改
            </button>
        </div>
    </form>
</div>
</body>
<script type="text/javascript">
    $(document).on('click', '#L_repass', function () {
        submit();
    });
    function submit() {
        let payment = {
            paymentid: $("#paymentid").val(),
            orderid: $("#orderid").val(),
            paymenttime: $("#paymenttime").val(),
            paymentmount: $("#paymentmount").val(),
            paymentstatus: $("#paymentstatus").val(),
        };
        console.log(JSON.stringify(payment))
        $.ajax({
            url: "../payment/updatePayment",
            type: "post",
            datatype: "json",
            contentType: "application/json",
            data: JSON.stringify(payment),
            success: function (data) {
                console.log(data);
                layer.msg(data.message);
                window.parent.location.reload();//刷新父页面
                setTimeout(function (){
                    parent.layer.close(layer.index);//关闭弹出层
                },1000)
            },
            error: function (data) {
                layer.msg("修改失败！", {icon: 1});
            }
        })
    }
</script>
</html>